(function($){
	$.fn.customerListInit = function(){
		var $this = $(this);
		//客户类型
		$('#item',$this).combobox({
			data:TEA.getCustomerTypeList(),
			valueField:'dataDictionaryID',
			textField:'dataDictionaryName',
			width:150
		})
		//门店下拉框
		$('#shop',$this).combobox({
			data:TEA.getShopList(),
			valueField:'dataDictionaryID',
			textField:'dataDictionaryName',
			width:150
		})
		//查询
		$('#search',$this).click(function(){
			var queryContent = $('.queryContent',$this);
			var shopID = $('#shop',$this).combobox('getValue');
			var customerTypeID = $('#item',$this).combobox('getValue');
			var customerCode = $('#customerCode',queryContent).val();
			var customerName = $('#customerName',queryContent).val();
			
			var url ='customer!query.action';
			var content = {'shop.dataDictionaryID':shopID,customerTypeID:customerTypeID,customerCode:customerCode,customerName:customerName};
			
			$('#customerList',$this).datagrid({
				url:url,
				queryParams:content,
				pageNumber:1
			});
		})
		//重置
		$('#reset',$this).click(function(){
			var queryContent = $('.queryContent',$this);
			$('#shop',$this).combobox('clear');
			$('#item',$this).combobox('clear');
			$('#customerCode',queryContent).val('');
			$('#customerName',queryContent).val('');
		})
		//加载列表
		$('#customerList',$this).datagrid({
			singleSelect:true,
			fit:true,
			method:"POST",
			nowrap:true,
			striped: true,
			collapsible:true,
			rownumbers:true,
			pagination:true,
			pageSize:30,
			columns:[[
				{field:'customerID',hidden:true},
				{field:'customerTypeID',hidden:true},
				{field:'customerSourceID',hidden:true},
				{field:'customerCode',title:'客户编号',width:100,align:"center"},
				{field:'customerName',title:'客户名称',width:100,align:"center"},
				{field:'customerTypeName',title:'客户类型',width:100,align:"center"},
				{field:'customerSourceName',title:'客户类型',width:100,align:"center"},
				{field:'sex',title:'性别',width:100,align:"center"},
				{field:'birthday',title:'生日',width:100,align:"center"},
				{field:'character',title:'性格特点',width:100,align:"center"},
				{field:'company',title:'公司',width:200,align:"center"},
				{field:'roleName',title:'职位',width:100,align:"center"},
				{field:'telephone',title:'电话',width:100,align:"center"},
				{field:'address',title:'地址',width:100,align:"center"},
				{field:'note',title:'备注',width:300,align:"center"}
			]]
		});
	}
})(jQuery);